﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;

namespace Meteorite
{
    public class LogoScene : CCScene
    {
        const float time1 = 0.5f;
        const float time2 = 0.8f;
        const float time3 = 0.3f;

        public override void  onEnter()
        {
 	        base.onEnter();

	        CCSize size = CCDirector.sharedDirector().getWinSize();

            CCLayerColor layer = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 255, 255, 255), size.width, size.height);
            this.addChild(layer, -1);

            CCLabelTTF pLabel = CCLabelTTF.labelWithString("Gel Studio", "Arial", 24);
            pLabel.position = new CCPoint(size.width / 2, size.height/2);
            //pLabel.Color = new ccColor4B(255, 255, 255, 0);
            this.addChild(pLabel, 1);
           
#if DEBUG
            CCFiniteTimeAction act = CCFadeIn.actionWithDuration(0.2f);
            CCFiniteTimeAction act1 = CCFadeOut.actionWithDuration(0.1f);
            pLabel.runAction(CCSequence.actions(act, CCDelayTime.actionWithDuration(0.3f), act1,CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback))));

#else
            CCFiniteTimeAction act = CCFadeIn.actionWithDuration(time1);
            CCFiniteTimeAction act1 = CCDelayTime.actionWithDuration(time2);
            CCFiniteTimeAction act2 = CCFadeOut.actionWithDuration(time3);
            pLabel.runAction(CCSequence.actions(act,act1,act2));

            
            CCSprite Powered = CCSprite.spriteWithFile(GameConstant.Texture_Powered);
            Powered.position = new CCPoint(size.width / 2, size.height / 2);
            Powered.visible = false;
            this.addChild(Powered, 1);

            CCFiniteTimeAction act4 = CCDelayTime.actionWithDuration(time1 + time2 + time3);

            Powered.runAction(CCSequence.actions(act4, CCShow.action(), act, act1, act2, CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback))));
#endif
        }

        public LogoScene()
        {
            
        }
       
        public void callback()
        {
            CCScene pScene = new MainMenuScene();
            //CCScene pScene = new GameScene();
            CCDirector.sharedDirector().replaceScene(pScene);
        }
    }
}
